package com.dz.Incubator.service.impl;

import com.dz.Incubator.dao.CompanyInfoDao;
import com.dz.Incubator.service.CompanyInfoService;
import com.dz.Incubator.config.Pagination;
import com.dz.Incubator.entity.CompanyInfoEntity;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

@Service
public class CompanyInfoServiceImpl implements CompanyInfoService {

	private static final Logger logger = LoggerFactory.getLogger(CompanyInfoService.class);

    @Autowired
    private CompanyInfoDao companyInfoDao;

    @Override
    public CompanyInfoEntity insert(CompanyInfoEntity companyInfoEntity) {
        companyInfoDao.insert(companyInfoEntity);
        
        return companyInfoEntity;
    }

    @Override
    public CompanyInfoEntity update(CompanyInfoEntity companyInfoEntity) {
        companyInfoDao.update(companyInfoEntity);
        
        return companyInfoEntity;
    }

    @Override
    public Integer delete(Long id) {
        int ret = companyInfoDao.delete(id);
        return ret;
    }
    
    @Override
    public List<CompanyInfoEntity> find(Long[] ids) {
        List<CompanyInfoEntity> datas = companyInfoDao.find(ids);
        return datas;
    }

    @Override
    public CompanyInfoEntity get(Long id) {
        CompanyInfoEntity companyInfoEntity = companyInfoDao.get(id);
        return companyInfoEntity;
    }

    @Override
    public List<CompanyInfoEntity> findAll() {
    	List<CompanyInfoEntity> datas = companyInfoDao.findAll();
    	return datas;
    }
    
    @Override
    public Pagination findByPagination(Pagination pagination) {
    	List<CompanyInfoEntity> datas = companyInfoDao.findByPagination(pagination);
    	pagination.setList(datas);
    	return pagination;
    }
	
	@Override
    public List<CompanyInfoEntity> insertBatch(List<CompanyInfoEntity> list) {
        int ret = companyInfoDao.insertBatch(list);
        return list;
    }
    
    @Override
    public List<CompanyInfoEntity> updateBatch(List<CompanyInfoEntity> list) {
        int ret = companyInfoDao.updateBatch(list);
        return list;
    }
    
    @Override
    public List<Long> deleteBatch(Long[] ids) {
        int ret = companyInfoDao.deleteBatch(ids);
        List<CompanyInfoEntity>  datas = companyInfoDao.find(ids);
        List<Long> list = new ArrayList<Long>();
        for (CompanyInfoEntity data : datas) {
        	list.add(data.getId());
        }
        return list;
    }
}